package forms;

import org.apache.struts.action.ActionForm;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;


public class DisciplineSubmitForm extends ActionForm {
	private static final long serialVersionUID = 1L;
	private String major = null;
	private String title_degree = null;
	private String date = null;
	private Double gpa = 0.0;
	private String transcript = null;
	
	public String getMajor() {
		return major;
	}
	public void setMajor(String major) {
		this.major = major;
	}
	public String getTitle_degree() {
		return title_degree;
	}
	public void setTitle_degree(String title_degree) {
		this.title_degree = title_degree;
	}
	public String getDate() {
		return date;
	}
	public void setDate(String date) {
		this.date = date;
	}
	public Double getGpa() {
		return gpa;
	}
	public void setGpa(Double gpa) {
		this.gpa = gpa;
	}
	public String getTranscript() {
		return transcript;
	}
	public void setTranscript(String transcript) {
		this.transcript = transcript;
	}
	
	public ActionErrors validate(ActionMapping mapping, HttpServletRequest request){
		ActionErrors errors = new ActionErrors();
		
		if ((major == null) || (major.length() < 1))
			errors.add("majorMsgTagl", new ActionMessage("errors.required", "Major"));
		
		if (title_degree == null) 
			errors.add("titleMsgTagl", new ActionMessage("errors.required", "Degree Title"));
		
		if ((date == null) || (date.length() != 5))
			errors.add("majorMsgTagl", new ActionMessage("errors.required", "Date"));
		
		if ((gpa == 0.0)||(gpa > 5.0)) 
			errors.add("gpaMsgTagl", new ActionMessage("errors.required", "GPA"));
		
		return errors;
	}
}
	
